package org.example.mapper;

import org.example.domain.User2;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 李新雨的项目86176
 * @version 1.0
 * @date 2024-12-15 12:32
 */
public class DateMapper2 {
    //用户集合    用户名---用户
    private static Map<String, User2> userData = new HashMap<String, User2>();
    //角色集合    用户名---角色集合
    private static Map<String, List<String>> roleData = new HashMap<String, List<String>>();
    //权限集合    用户名---权限集合
    private static Map<String, List<String>> permissionData = new HashMap<String, List<String>>();
    static{
        //初始化用户数据
        User2 u1 = new User2("lanxw","1fca7051de685797cecb55cfd7b44396","1");
        userData.put(u1.getUsername(),u1);
        roleData.put(u1.getUsername(), Arrays.asList("seller"));
        permissionData.put(u1.getUsername(),
                Arrays.asList("customer:list","customer:save"));

        User2 u2 = new User2("yl","ef367b05f0d9e4fc39c9e58cd45ba413","2");
        userData.put(u2.getUsername(),u2);
        roleData.put(u2.getUsername(), Arrays.asList("seller","hr"));
        permissionData.put(u2.getUsername(),
                Arrays.asList("customer:list","customer:save","user:list","user:delete"));
    }
    //提供静态方法，模拟数据库返回数据
    public static User2 getUserByName(String username){
        return userData.get(username);
    }
    public static List<String> getRoleByName(String username){
        return roleData.get(username);
    }
    public static List<String> getPermissionByName(String username){
        return permissionData.get(username);
    }

}
